package cn.cerc.sample.forms;

import javax.servlet.annotation.WebListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import cn.cerc.db.core.IHandle;
import cn.cerc.mis.queue.AbstractObjectQueue;

@Component
@WebListener
public class QueueTest2 extends AbstractObjectQueue<TestQueueObject> {
    private static final Logger log = LoggerFactory.getLogger(QueueTest2.class);

    @Override
    public Class<TestQueueObject> getClazz() {
        return TestQueueObject.class;
    }

    // 在此处理具体的业务逻辑
    @Override
    public boolean execute(IHandle handle, TestQueueObject data) {
        try {
            log.info("{} 检测到消息，处理线程: {}", this.getClass().getSimpleName(), Thread.currentThread());
            log.info("message handle corpNo: {}", handle.getCorpNo());
            log.info("user: {}", data.getUser());
            return true;
        } catch (Exception e) {
            log.error(e.getMessage());
            e.printStackTrace();
            return false;
        }
    }

}
